/*
   Copyright 2009 Abdulla Abdurakhmanov (abdulla@latestbit.com)
   Original sources are available at www.latestbit.com

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/

package org.latestbit.smartobjects.core;

import java.io.IOException;

import org.latestbit.smartobjects.coders.CallInterfaceOperationRequest;
import org.latestbit.smartobjects.coders.CallInterfaceOperationResponse;
import org.latestbit.smartobjects.exceptions.*;
import org.latestbit.smartobjects.io.ResizableByteBuffer;
import org.latestbit.smartobjects.network.ConnectionHandler;


public class DummySyncServerObject extends ServerSkeleton {
	
	public static final byte[] TEST_BUFFER = new byte[] {0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F }; 

	public DummySyncServerObject( ) throws SmartBusSystemException, InterruptedException {
	}
	
	@Override
	public String getInterfaceId() {
		return  DummySyncServerObject.class.getName();
	}

	@Override
	public String[] getSupportedInterfaces() {
		return null;
	}	

	@Override
	public void onCallRequestReceived(ConnectionHandler handler, CallInterfaceOperationRequest callRequest) throws SmartBusSystemException, IOException {
				
		ResizableByteBuffer writeBuffer = callRequest.getBuffer();
		writeBuffer.getBuffer().clear();
		
		// ResizableByteBuffer writeBuffer = new ResizableByteBuffer(false, 1024, 65535, 1024);
		CallInterfaceOperationResponse callResponse = callRequest.createResponse(writeBuffer);
		
		callResponse.beginSerialize();
		writeBuffer.put(TEST_BUFFER);
		callResponse.finishSerialize();
		// 
		sendResponse ( handler, callResponse );
	}

}
